<?php 

/**
 * 入库管理
 * @copyright   Copyright (c) 2006 - 2010 DZH 友拓软件友拓通
 * @category    基本信息
 * @package   Action
 * @author     庄敏学
 * @version  2.1,2012-07-22
 */

class InstockPublicAction extends RelationCommonAction {
	
	public $_email_object_id 		=	'factory_id';//默认客户 其余 factory_id
	
	public function add(){
		$id	=	intval($_GET['id']);	
		if ($id > 0) {	
			// 待入库时获取默认值
			$name 		= $this->getActionName();
			$model 		= D($name);  
			$model->setId($id);
			$this->rs	= $model->getLoad();
		}
	}
	
	public function waitInstock(){
		$this->list	= D('Instock')->waitInstock();
		
		if ($_POST['search_form']) {
			$this->display ('waitList');
		}else {
			$this->display('waitInstock');
		}
	}
	
	/**
	 * email发送的对象 例如销售单给客户 入库单发送给多个厂家
	 *
	 * @param array $info
	 * @return array
	 */
	public function flowEmailInfo($info){
		if ($info['id']>0){
			$model	=	M('instock_detail');
			$info	=	 $model->where('instock_id='.$info['id'])->group('factory_id')->select(); 
			return $info;
		} 
	}
	
	/**
	 * Enter description here...
	 *
	 * @param array $info
	 * @param array $email_address
	 */
	public function flowEmailDetail($info,$email_address){ 
		$info	= array('email_address'=>$email_address,'post'=>array('comp_id'=>$info['factory_id']));
		return $info;
	}
	
}